package com.woniuxy.dudugua.service.impl;

import com.woniuxy.dudugua.entity.Product;
import com.woniuxy.dudugua.entity.ProductExample;
import com.woniuxy.dudugua.mapper.ProductMapper;
import com.woniuxy.dudugua.service.ProductService;
import com.woniuxy.dudugua.util.view.ProView;
import com.woniuxy.dudugua.util.view.ProductInfoView;
import com.woniuxy.dudugua.util.view.ProductView;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class ProductServiceImpl implements ProductService {
    @Resource
    private ProductMapper productMapper;


    @Override
    public ProductInfoView getProductById(Integer id) {
        return productMapper.selectById(id);
    }

    @Override
    public long countByExample(Map<String, Object> params) {
        return productMapper.countByExample(null);
    }

    @Override
    public List<ProductView> selectByExample(Map<String, Object> params) {
        return productMapper.selectDetailByExample(params);
    }

    @Override
    public List<ProView> getPro() {
        return productMapper.selectPro();
    }

    @Override
    public Product getMax() {
        return productMapper.selectMax();
    }

    @Override
    public int insertProduct(Product product) {
        int id = productMapper.insert(product);
        return id;
    }
}
